<?php
namespace app\api\model;

class ActivityModel extends BaseModel
{
    function list($limit, $pages) {
        $time = time();
        $list = db('activity')
        // ->where('end_time','not between','1,'.$time)
        ->order('id desc')
        ->page($pages, $limit)
            ->select();
        return $list;
    }
    public function cate($list)
    {
        $leng = count($list);
        for ($i = 0; $i < $leng; $i++) {

            $cate_id = $list[$i]['cate_id'];
            switch ($cate_id) {
                case 1:
                    $list[$i]['cate'] = '普通活动';
                    break;
                case 2:
                    $list[$i]['cate'] = '房间活动';
                    break;
                case 3:
                    $list[$i]['cate'] = '优惠券活动';
                    break;
                case 4:
                    $list[$i]['cate'] = '次卡活动';
                    break;
                case 5:
                    $list[$i]['cate'] = '充值卡活动';
                    break;
            }
        }
        return $list;
    }
    public function info($id)
    {
        $list = db('activity')
            ->where(['id' => $id])
            ->find();
        if (isset($list)) {
            switch ($list['cate_id']) {
                case 1:
                    $list['cate'] = '普通活动';
                    break;
                case 2:
                    $list['cate'] = '房间活动';
                    break;
                case 3:
                    $list['cate'] = '优惠券活动';
                    break;
                case 4:
                    $list['cate'] = '次卡活动';
                    break;
                case 5:
                    $list['cate'] = '充值卡活动';
                break;
            }
        return $list;
        }else{
            return $list;
        }

    }
}
